import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import History from '@/views/pages/History'
import Togeser from '@/views/pages/Togeser'
import Company from '@/views/pages/Company'
import DataBrain from '@/views/pages/DataBrain'
import painPoint from '@/views/pages/painPoint'
import Intelligence from '@/views/pages/Intelligence'
import IntelligentSolution from '@/views/pages/IntelligentSolution'
import Fuse from '@/views/pages/Fuse'
import Consumption from '@/views/pages/Consumption'
import Consum from '@/views/pages/Consum'
// 解决重复点击路由报错的BUG
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err)
}

Vue.use(VueRouter)

const routes = [{
  path: '/',
  name: 'Home',
  component: Home,
  redirect: {
    name: "Company"
  },
  children: [{
    path: '/history',
    name: 'History',
    component: History,
    meta: {
      tittle: '发展历程',
      className: 'background_his'
    }
  },  {
    path: '/company',
    name: 'Company',
    component: Company,
    meta: {
      tittle: '消费金融产业互联模式',
      className: 'background_his'
    }
  },{
    path: '/consum',
    name: 'Consum',
    component: Consum,
    redirect: {
      name: "IntelligentSolution"
    },
    children:[
      {
        path: '/consum/IntelligentSolution',
        name: 'IntelligentSolution',
        component: IntelligentSolution,
        meta:{
          tittle:'智能化产品开发步骤和方法',
          className:'background_his'
        }
      },{
        path: '/consum/consumption',
        name: 'Consumption',
        component: Consumption,
        meta:{
          tittle:'消费金融数字化平台',
          className:'background_his'
        }
      }
    ]
  },
   {
    path: '/brain',
    name: 'DataBrain',
    component: DataBrain,
    redirect:{
      name:'painPoint'
    },
    children:[
      {
        path: '/brain/painpoint',
        name: 'painPoint',
        component: painPoint,
        meta:{
          tittle:'产业互联解决方案',
          className:'background_his'
        }
      },{
        path: '/brain/togeser',
        name: 'Togeser',
        component: Togeser,
        meta: {
          tittle: '消费金融产业互联模式',
          className: 'background_his'
        }
      },{
        path: '/brain/intelligence',
        name: 'Intelligence',
        component: Intelligence,
        meta:{
          tittle:'智能匹配模型',
          className:'background_his'
        }
      },{
        path: '/brain/fuse',
        name: 'Fuse',
        component: Fuse,
        meta:{
          tittle:'融器产业服务体系',
          className:'background_his'
        }
      },
    ]
  }]
}]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router